﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Biblioteca.fachada;
using Biblioteca.classesBasicas.equipamento;

namespace Desktop.views.cruds.crudsEquipamento.crudColete
{
    public partial class MenuColete : Form
    {
        private MenuEquipamento menuEquipamento;
        private Fachada fachada = new Fachada();
        private List<Colete> listaColetes;
        private Colete colete = new Colete();
        

        public MenuColete(MenuEquipamento menuEquipamento)
        {
           
            
            // TODO: Complete member initialization
            this.menuEquipamento = menuEquipamento;
            menuEquipamento.Hide();
            InitializeComponent();
        }

        private void buttonCadastrar_Click(object sender, EventArgs e)
        {
            CadastroColete cadastroColete = new CadastroColete(this);
            cadastroColete.ShowDialog();
        }

        private void buttonSair_Click(object sender, EventArgs e)
        {
            menuEquipamento.Show();
            this.Dispose();
        }

        private void MenuColete_FormClosed(object sender, FormClosedEventArgs e)
        {
            menuEquipamento.Show();
            this.Dispose();
        }

        private void MenuColete_Load(object sender, EventArgs e)
        {
            this.carregarGridViewColete();
        }


        private void dataGridViewColete_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex > -1)
            {
                DataGridViewRow row = this.dataGridViewColete.Rows[e.RowIndex];

                colete.Id = row.Cells[0].Value.ToString();
                colete.Nome = row.Cells[1].Value.ToString();
                colete.Tipo = row.Cells[2].Value.ToString();
                colete.Marca = row.Cells[3].Value.ToString();
                colete.Valor = row.Cells[4].Value.ToString();

                AlterarRemoverColete alterar = new AlterarRemoverColete(this, colete);
                alterar.ShowDialog();
            }
        }      


        public void carregarGridViewColete()
        {
            listaColetes = fachada.listarColete();

            DataGridViewCellStyle columnHeaderStyle =
            new DataGridViewCellStyle();
            columnHeaderStyle.BackColor = Color.Aqua;
            columnHeaderStyle.Font =
                new Font("Verdana", 10, FontStyle.Bold);
            this.dataGridViewColete.ColumnHeadersDefaultCellStyle =
                columnHeaderStyle;

            dataGridViewColete.DataSource = listaColetes;

            this.dataGridViewColete.Columns[0].HeaderText = "ID";
            this.dataGridViewColete.Columns[1].HeaderText = "NOME";
            this.dataGridViewColete.Columns[2].HeaderText = "TIPO";
            this.dataGridViewColete.Columns[3].HeaderText = "MARCA";
            this.dataGridViewColete.Columns[4].HeaderText = "VALOR";
        }
        
    }
}
